//
//  AWAdaptiveMacro.h
//  AmberWeather
//
//  Created by LeeSongtao on 16/3/4.
//  Copyright © 2016年 Amber Weather. All rights reserved.
//

#ifndef THAdaptiveMacro_h
#define THAdaptiveMacro_h


#define kScreenHeight   [UIScreen mainScreen].bounds.size.height
#define kScreenWidth    [UIScreen mainScreen].bounds.size.width
#define kScreenRect     [UIScreen mainScreen].bounds
#define kCardViewWidth  (AWScreenWidth - AWMargin * 2)
#define kTabBarHeight              49.
#define kButtonHeight              44.
#define kNavigationBarHeight       44.
#define kTableviewCellHeight       44.
#define kStatusBarHeight           20.
#define kNavigationAndStateBarHeight  64.

#define oldDateDefault @"oldDateDefault"

//#define IS_PhoneNum @"^((13[0-9])|(147)|(15[^4,\\D])|(18[0-9]))\\d{8}$"
#define IS_PhoneNum @"^[\\+0-9]{5,20}$"
#define NUM @"0123456789"

#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
#define MB_MULTILINE_TEXTSIZE(text, font, maxSize, mode) [text length] > 0 ? [text \
boundingRectWithSize:maxSize options:(NSStringDrawingUsesLineFragmentOrigin) \
attributes:@{NSFontAttributeName:font} context:nil].size : CGSizeZero;
#else
#define MB_MULTILINE_TEXTSIZE(text, font, maxSize, mode) [text length] > 0 ? [text \
sizeWithFont:font constrainedToSize:maxSize lineBreakMode:mode] : CGSizeZero;
#endif

#define IOS7Less   (([[[UIDevice currentDevice] systemVersion] floatValue] < 8.0) ? 1 : 0)
#define IOS7Later   (([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) ? 1 : 0)
#define IOS8Later   (([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) ? 1 : 0)
#define IOS9Later   (([[[UIDevice currentDevice] systemVersion] floatValue] >= 9.0) ? 1 : 0)
#define IOS10Later   (([[[UIDevice currentDevice] systemVersion] floatValue] >= 10.0) ? 1 : 0)

#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)


#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_RETINA ([[UIScreen mainScreen] scale] >= 2.0)

#define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
#define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
#define SCREEN_MAX_LENGTH (MAX(SCREEN_WIDTH, SCREEN_HEIGHT))
#define SCREEN_MIN_LENGTH (MIN(SCREEN_WIDTH, SCREEN_HEIGHT))

#define IS_IPHONE_4_OR_LESS (IS_IPHONE && SCREEN_MAX_LENGTH < 568.0)
#define IS_IPHONE_5 (IS_IPHONE && SCREEN_MAX_LENGTH == 568.0)
#define IS_IPHONE_5_OR_LESS (IS_IPHONE && SCREEN_MAX_LENGTH <= 568.0)
#define IS_IPHONE_6 (IS_IPHONE && SCREEN_MAX_LENGTH == 667.0)
#define IS_IPHONE_6_OR_LESS (IS_IPHONE && SCREEN_MAX_LENGTH <= 667.0)
#define IS_IPHONE_6P (IS_IPHONE && SCREEN_MAX_LENGTH == 736.0)

#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000
#define FTTextAlignmentCenter   NSTextAlignmentCenter
#define FTTextAlignmentRight    NSTextAlignmentRight
#define FTTextAlignmentLeft     NSTextAlignmentLeft
#define FTAttributeTextColor    NSForegroundColorAttributeName
#define FTAttributeTextFont     NSFontAttributeName
#else
#define FTTextAlignmentCenter   UITextAlignmentCenter
#define FTTextAlignmentRight    UITextAlignmentRight
#define FTTextAlignmentLeft     UITextAlignmentLeft
#define FTAttributeTextColor    UITextAttributeTextColor
#define FTAttributeTextFont     UITextAttributeFont
#endif


#endif /* AWAdaptiveMacro_h */
